home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_217 / stevie / stevie.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  7KB  |  329 lines

  1. /*
  2.  * STEVIE - Simply Try this Editor for VI Enthusiasts
  3.  *
  4.  * Code Contributions By : Tim Thompson           twitch!tjt
  5.  *                         Tony Andrews           onecom!wldrdg!tony 
  6.  *                         G. R. (Fred) Walter    watmath!watcgl!grwalter 
  7.  */
  8.  
  9. #include "env.h"
  10.  
  11. #include <stdio.h>
  12. #ifndef ATARI
  13. # ifndef UNIX
  14. #   include <stdlib.h>
  15. # endif
  16. #endif
  17. #include <ctype.h>
  18. #ifndef MWC
  19. # include <string.h>
  20. #endif
  21. #include "ascii.h"
  22. #include "keymap.h"
  23. #include "param.h"
  24. #include "term.h"
  25. #include "macros.h"
  26.  
  27. #ifdef AMIGA
  28. /*
  29.  * This is used to disable break signal handling.
  30.  */
  31. #include <signal.h>
  32. #endif
  33.  
  34. extern char    *strchr();
  35.  
  36. #define NORMAL             0
  37. #define CMDLINE             1
  38. #define INSERT             2
  39. #define APPEND             3
  40. #define UNDO             4
  41. #define REDO             5
  42. #define PUT             6
  43. #define FORWARD             7
  44. #define BACKWARD         8
  45. #define VALID             9
  46. #define NOT_VALID        10
  47. #define VALID_TO_CURSCHAR    11
  48. #define UPDATE_CURSOR           12
  49. #define UPDATE_ALL              13
  50.  
  51. /*
  52.  * Boolean type definition and constants 
  53.  */
  54. typedef int     bool_t;
  55.  
  56. #ifndef    TRUE
  57. # define    FALSE    (0)
  58. # define    TRUE    (1)
  59. #endif
  60. #define    SORTOF    (2)
  61. #define YES      TRUE
  62. #define NO       FALSE
  63. #define MAYBE    SORTOF
  64.  
  65. /*
  66.  * Maximum screen dimensions
  67.  */
  68. #define MAX_COLUMNS 140L
  69.  
  70. /*
  71.  * Buffer sizes
  72.  */
  73. #define CMDBUFFSIZE MAX_COLUMNS    /* size of the command processing buffer */
  74.  
  75. #define LSIZE        512    /* max. size of a line in the tags file */
  76.  
  77. #define IOSIZE     (1024+1)    /* file i/o and sprintf buffer size */
  78.  
  79. #define YANKSIZE    5200    /* yank buffer size */
  80. #define INSERT_SIZE 5300    /* insert, redo and undo buffer size must be
  81.                  * bigger than YANKSIZE */
  82. #define REDO_UNDO_SIZE 5400    /* redo, undo and (undo an undo) buffer size
  83.                  * must be bigger than INSERT_SIZE */
  84. #define READSIZE    5500    /* read buffer size must be bigger than
  85.                  * YANKSIZE and REDO_UNDO_SIZE */
  86.  
  87. /*
  88.  * SLOP is the amount of extra space we get for text on a line during editing
  89.  * operations that need more space. This keeps us from calling alloc every
  90.  * time we get a character during insert mode. No extra space is allocated
  91.  * when the file is initially read. 
  92.  */
  93. #define    SLOP    10
  94.  
  95. /*
  96.  * LINEINC is the gap we leave between the artificial line numbers. This
  97.  * helps to avoid renumbering all the lines every time a new line is
  98.  * inserted. 
  99.  *
  100.  * Since line numbers are stored in longs (32 bits), a LINEINC of 10000
  101.  * lets us have > 200,000 lines and we won't have to renumber very often.
  102.  */
  103. #define    LINEINC    10000
  104.  
  105. #define CHANGED    Changed = TRUE
  106. #define UNCHANGED  Changed = FALSE
  107.  
  108. #define S_NOT_VALID NumLineSizes = -1
  109.  
  110. #define S_LINE_NOT_VALID LineNotValid = TRUE
  111.  
  112. #define S_CHECK_TOPCHAR_AND_BOTCHAR CheckTopcharAndBotchar = TRUE
  113.  
  114. #define S_MUST_UPDATE_BOTCHAR MustUpdateBotchar = TRUE
  115.  
  116. #define S_VALID_TO_CURSCHAR ValidToCurschar = TRUE
  117.  
  118. struct line {
  119.     struct line    *next;    /* next line */
  120.     struct line    *prev;    /* previous line */
  121.     char           *s;        /* text for this line */
  122.     int             size;    /* actual size of space at 's' */
  123.     unsigned long   num;    /* line "number" */
  124. };
  125.  
  126. #define    LINEOF(x)    ((x)->linep->num)
  127.  
  128. struct lptr {
  129.     struct line    *linep;    /* line we're referencing */
  130.     int             index;    /* position within that line */
  131. };
  132.  
  133. typedef struct line LINE;
  134. typedef struct lptr LPtr;
  135.  
  136. struct charinfo {
  137.     char            ch_size;
  138.     char           *ch_str;
  139. };
  140.  
  141. extern struct charinfo chars[];
  142.  
  143. extern int      State;
  144. extern int      Rows;
  145. extern int      Columns;
  146. extern int      CheckTopcharAndBotchar;
  147. extern int      MustUpdateBotchar;
  148. extern int      ValidToCurschar;
  149. extern int      LineNotValid;
  150. extern int      NumLineSizes;
  151. extern LINE   **LinePointers;
  152. extern char    *LineSizes;
  153. extern char    *Filename;
  154. extern LPtr    *Filemem;
  155. extern LPtr    *Filetop;
  156. extern LPtr    *Fileend;
  157. extern LPtr    *Topchar;
  158. extern LPtr    *Botchar;
  159. extern LPtr    *Curschar;
  160. extern LPtr    *Insstart;
  161. extern int      Cursrow, Curscol, Cursvcol, Curswant;
  162. extern bool_t   set_want_col;
  163. extern int      Prenum;
  164. extern bool_t   Changed;
  165. extern bool_t   RedrawingDisabled;
  166. extern bool_t   UndoInProgress;
  167. extern bool_t   Binary;
  168. extern char    *IObuff;
  169. extern char    *Insbuffptr;
  170. extern char    *Insbuff;
  171. extern char    *Readbuffptr;
  172. extern char    *Readbuff;
  173. extern char    *Redobuffptr;
  174. extern char    *Redobuff;
  175. extern char    *Undobuffptr;
  176. extern char    *Undobuff;
  177. extern char    *UndoUndobuffptr;
  178. extern char    *UndoUndobuff;
  179. extern char    *Yankbuffptr;
  180. extern char    *Yankbuff;
  181. extern char     last_command;
  182. extern char     last_command_char;
  183.  
  184. extern char    *strcpy();
  185.  
  186. /* alloc.c */
  187. char  *alloc();
  188. char  *strsave();
  189. void   screenalloc();
  190. void   filealloc();
  191. void   freeall();
  192. LINE  *newline();
  193. bool_t canincrease();
  194.  
  195. /* cmdline.c */
  196. void   readcmdline();
  197. void   dotag();
  198. void   msg();
  199. void   emsg();
  200. void   smsg();
  201. void   gotocmdline();
  202. void   wait_return();
  203.  
  204. /* dec.c */
  205. int    dec();
  206.  
  207. /* edit.c */
  208. void   edit();
  209. void   insertchar();
  210. void   getout();
  211. void   scrollup();
  212. void   scrolldown();
  213. void   beginline();
  214. bool_t oneright();
  215. bool_t oneleft();
  216. bool_t oneup();
  217. bool_t onedown();
  218.  
  219. /* fileio.c */
  220. void   filemess();
  221. void   renum();
  222. bool_t readfile();
  223. bool_t writeit();
  224.  
  225. /* s_io.c */
  226. void   s_clear();
  227. void   s_refresh();
  228. void   NotValidFromCurschar();
  229. void   Update_Botchar();
  230.  
  231. /* help.c */
  232. bool_t help();
  233.  
  234. /* inc.c */
  235. int    inc();
  236.  
  237. /* linefunc.c */
  238. LPtr  *nextline();
  239. LPtr  *prevline();
  240. void   coladvance();
  241.  
  242. /* main.c */
  243. void   stuffReadbuff();
  244. void   stuffnumReadbuff();
  245. char   vgetc();
  246. char   vpeekc();
  247.  
  248. /* mark.c */
  249. void   setpcmark();
  250. void   clrall();
  251. void   clrmark();
  252. bool_t setmark();
  253. LPtr  *getmark();
  254.  
  255. /* misccmds.c */
  256. bool_t OpenForward();
  257. bool_t OpenBackward();
  258. void   fileinfo();
  259. void   inschar();
  260. void   insstr();
  261. void   delline();
  262. bool_t delchar();
  263. int    cntllines();
  264. int    plines();
  265. LPtr  *gotoline();
  266.  
  267. /* normal.c */
  268. void   normal();
  269. void   ResetBuffers();
  270. void   AppendToInsbuff();
  271. void   AppendToRedobuff();
  272. void   AppendNumberToRedobuff();
  273. void   AppendToUndobuff();
  274. void   AppendNumberToUndobuff();
  275. void   AppendPositionToUndobuff();
  276. void   AppendToUndoUndobuff();
  277. void   AppendNumberToUndoUndobuff();
  278. void   AppendPositionToUndoUndobuff();
  279. bool_t linewhite();
  280.  
  281. /* mk.c */
  282. char  *mkstr();
  283. char  *mkline();
  284.  
  285. /* param.c */
  286. void   doset();
  287.  
  288. /* screen.c */
  289. void   cursupdate();
  290.  
  291. /* search.c */
  292. void   doglob();
  293. void   dosub();
  294. void   searchagain();
  295. bool_t dosearch();
  296. bool_t repsearch();
  297. bool_t searchc();
  298. bool_t crepsearch();
  299. bool_t findfunc();
  300. LPtr  *showmatch();
  301. LPtr  *fwd_word();
  302. LPtr  *bck_word();
  303. LPtr  *end_word();
  304.  
  305. /* format_l.c */
  306. char *format_line();
  307.  
  308. /*
  309.  * Machine-dependent routines. 
  310.  */
  311. #ifdef AMIGA
  312. # include "amiga.h"
  313. #endif
  314. #ifdef BSD
  315. # include "bsd.h"
  316. #endif
  317. #ifdef UNIX
  318. # include "unix.h"
  319. #endif
  320. #ifdef TOS
  321. # include "tos.h"
  322. #endif
  323. #ifdef OS2
  324. # include "os2.h"
  325. #endif
  326. #ifdef DOS
  327. # include "dos.h"
  328. #endif
  329.